home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Lattice C v5.02 d4.adf
/
examples
/
debugger
/
whichis.cpr
< prev
Wrap
Text File
|
1988-11-07
|
2KB
|
97 lines
/*
Usage: Whichis [ <command> | 0xnnnnnn | n]
Version 1.00 02-Nov-88
Identifies the CLI process associated with a given command, task number
or task address
*/
parse arg name '0x' tsk .
NULL = "00000000"x
if (name = '?') then
do
do i = 2 to 6
'd "'||strip(sourceline(i),'T',"0a"x) '"'
end
exit(0)
end
else if (name ~= '') then
do
if datatype(name, 'W') then
do
clinum = name
name = 'Process' name
end
else
cliname = name
end
else if (tsk ~= '') then
do
name = right(tsk,8,'0')
taskbase = x2c(name)
name = '0x'||name
end
else
do
'd "No task given to locate"'
exit(0)
end
/* Show all CLI tasks */
dosbase = findlib("dos.library")
rootnode = import(offset(dosbase,34),4)
tasktable = d2c(c2d(import(rootnode,4))*4,4)
taskcount = c2d(import(tasktable,4))
do tasknum = 1 to taskcount
proc = import(offset(tasktable,tasknum*4),4)
if (proc ~= NULL) then
do
proc = offset(proc,-92)
cli = d2c(c2d(import(offset(proc,172),4))*4,4)
command = 'No command loaded'
args = ''
module = ''
if (cli ~= NULL) then
do
cmdname = d2c(c2d(import(offset(cli,16),4))*4,4)
cmdlen = c2d(import(cmdname, 1))
module = import(offset(cmdname,1), cmdlen)
if cmdlen ~= 0 then
do
command = 'Command:' import(offset(cmdname,1), cmdlen)
cis = d2c(c2d(import(offset(cli,32),4))*4,4)
cptr = d2c(c2d(import(offset(cis,12),4))*4,4)
args = import(cptr,80)
args = translate(args,"'"||'0a0a'x,'"'||'0d00'x)
y = pos('0a'x, args)
if (y ~= 0) then args = left(args,y-1)
end
end
if (proc = taskbase | module = cliname | tasknum = clinum) then
do
'd "Process' tasknum||': 0x'||c2x(proc) command args'"'
exit(0)
end
end
end
'd "Unable to find' name '"'
exit(0)
/* Find a given library in the system */
findlib:
parse arg tofind
execbase = import("00000004"x,4)
liboff = 378
nodebase = import(offset(execbase, liboff), 4)
do while(import(nodebase,4) ~= NULL)
namestr = import(import(offset(nodebase,10),4))
if namestr = tofind then return nodebase
nodebase = import(nodebase,4)
end
'd "Could not find' tofind||'"'
exit(0)